package test_public;
import static org.junit.Assert.*;
import org.junit.Test;
import datamodel.rucksack.Rucksack;
import datamodel.tree.sequential.SequentialTree;
import datamodel.tree.sequential.SequentialTreeNode;

public class SequentialTreePublicTest {
	public SequentialTree lt = new SequentialTree();
	SequentialTreeNode currentNode = null;
	SequentialTreeNode root = new SequentialTreeNode(null);
	
	
	@Test
	public void moveToTest(){
		currentNode = root;
		Rucksack r = new Rucksack(10);
		SequentialTreeNode leftChild= new SequentialTreeNode(r);
		lt.setCurrentNode(currentNode);
		lt.setLeftNode(leftChild);
		
		assertEquals(true,lt.hasLeftNode());
		assertEquals(true,lt.moveToLeftNode());
		assertEquals(false,lt.hasRightNode());
		assertEquals(false,lt.moveToRightNode());
		assertEquals(lt.getCurrentNode().getRucksack(), r);
		
		
	}
	
	@Test 
	public void setterTest(){
		currentNode = root;
		SequentialTreeNode leftChild= new SequentialTreeNode(null);
		SequentialTreeNode rightChild = new SequentialTreeNode(null);
		lt.setCurrentNode(currentNode);
	    lt.setLeftNode(leftChild);
	    lt.setRightNode(rightChild);
		
		assertTrue(lt.hasLeftNode());
		assertTrue(lt.hasRightNode());
		
	}
	@Test
	public void moveToRootTest(){
		currentNode = root;
		Rucksack r = new Rucksack(10);
		root = new SequentialTreeNode(r);
		SequentialTreeNode leftChild= new SequentialTreeNode(null);
		SequentialTreeNode rightChild = new SequentialTreeNode(null);
		lt.setCurrentNode(currentNode);
	    lt.setLeftNode(leftChild);
	    lt.setRightNode(rightChild);
	    
	    
	    
	    assertTrue(lt.moveToRoot());
	}
	@Test
	public void clear(){
		currentNode = root;
		SequentialTreeNode leftChild= new SequentialTreeNode(null);
		SequentialTreeNode rightChild = new SequentialTreeNode(null);
		lt.setCurrentNode(currentNode);
	    lt.setLeftNode(leftChild);
	    lt.setRightNode(rightChild);
	    
	    lt.clearTree();
	    assertEquals(null, lt.getCurrentNode());
	    assertEquals(false, lt.hasLeftNode());
	    assertEquals(false, lt.hasRightNode());
	    assertEquals(false, lt.hasParentNode());
	    
	}
	

}
